language: php

php:
  - 7.2
  - 7.1
  - 7.0
  - 5.6
  - 5.5
  - 5.4
  - nightly

matrix:
  fast_finish: true
  include:
    - php: 5.3
      dist: precise
    - php: hhvm
      sudo: true
      dist: trusty
      group: edge # Use edge image until the next travis CI image update
      addons:
        postgresql: "9.3"
        apt:
          packages:
            - mysql-server-5.6
            - mysql-client-core-5.6
            - mysql-client-5.6
      services:
        - mysql
        - postgresql
        - redis-server
  allow_failures:
    - php: 5.3
    - php: nightly
    - php: hhvm # run build against hhvm but allow them to fail
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail

services:
  - redis-server
  - memcached

# cache vendor dirs
cache:
  directories:
    - vendor
    - $HOME/.composer/cache

install:
  - travis_retry composer self-update && composer --version
  - travis_retry composer update --prefer-dist --no-interaction
  - if [[ $TRAVIS_PHP_VERSION == 7.2 ]] || [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
        printf "autodetect\n" | pecl install mcrypt-snapshot;
    fi

before_script:
  # Disable the HHVM JIT for faster Unit Testing
  - if [[ $TRAVIS_PHP_VERSION = hhv* ]]; then echo 'hhvm.jit = 0' >> /etc/hhvm/php.ini; fi
  # Disable DEPRECATE messages during PHPUnit initialization on PHP 7.2. To fix them, PHPUnit should be updated to 6.*
  - if [[ $TRAVIS_PHP_VERSION == 7.2 ]] || [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
      echo 'Disabled DEPRECATED notifications for PHP 7.2';
      echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> /tmp/php-config.ini;
      phpenv config-add /tmp/php-config.ini;
    fi
  - ./tests/travis/mysql-setup.sh
  - ./tests/travis/postgresql-setup.sh
  - ./tests/travis/memcache-setup.sh

script: cd tests && ../vendor/bin/phpunit --verbose --colors --no-globals-backup --exclude-group mssql,oci framework

